<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"><!--引入thymeleaf-->
<meta name="referrer" content="no-referrer" />
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body class="body">
<!--导航栏-->
<div th:fragment="copy">
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                        data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="/index" style="margin-left: 170px;">社区</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->

            <form class="navbar-form navbar-left">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="搜索内容">
                </div>
                <button type="submit" class="btn btn-default">搜索</button>
            </form>
            <!--根据session中是否存在user判断展示的内容-->
            <ul class="nav navbar-nav navbar-right">
                <li th:if="${session.user == null}"><a href="/login">登陆</a></li>
                <li th:if="${session.user} != null">
                    <a href="/personal/information">
                        <span class="glyphicon glyphicon glyphicon-envelope" aria-hidden="true"
                              style="padding-top: 2px;"></span>
                        <span  th:text="${session.unreadnum}" style="padding-top: 2px;"></span>
                    </a>
                </li>
                <li th:if="${session.user} != null"><a href="/publish">发布</a></li>
                <li class="dropdown" th:if="${session.user} != null">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false" style="margin-right: 190px;">
                        <span th:text="${session.user.getName()}"></span>
                        <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu" style="margin-right: 190px;">
                        <li><a href="/personal/questions">我的提问</a></li>
                        <li><a href="#">个人资料</a></li>
                        <li><a href="/logout">退出登陆</a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </nav>
</div>

</body>